package com.example.licslan.task;

import com.example.licslan.dao.UserDao;
import com.example.licslan.entity.User;
import lombok.Data;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @author WEILIN
 * 可以获取线程执行结果的线程
 */
@Data
public class TaskThread  implements Callable<Long> {

    private UserDao userDao;
    private List<User> userList;

    public TaskThread(UserDao userDao, List<User> userList) {
        this.userDao = userDao;
        this.userList = userList;
    }

    @Override
    public Long call() {
        //执行业务逻辑 批量写入2500条数据
        synchronized (this) {
            return userDao.creatUserList(userList);
        }
    }
}
